/*     */ package com.feeyin.radar.sys.dao.impl;
/*     */ 
/*     */ import com.feeyin.radar.commons.StringUtils;
/*     */ import com.feeyin.radar.sys.dao.BusinessTargetDAO;
/*     */ import com.feeyin.radar.sys.dao.ManageSetDAO;
/*     */ import com.feeyin.radar.sys.dao.RoleDAO;
/*     */ import com.feeyin.radar.sys.dao.UserDAO;
/*     */ import com.feeyin.radar.sys.model.ManageSet;
/*     */ import com.feeyin.radar.sys.model.ManageSetObject;
/*     */ import com.feeyin.radar.sys.model.Role;
/*     */ import com.feeyin.radar.sys.model.Users;
/*     */ import java.io.PrintStream;
/*     */ import java.math.BigDecimal;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import org.springframework.orm.ibatis.SqlMapClientTemplate;
/*     */ import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
/*     */ 
/*     */ public class ManageSetDAOImpl extends SqlMapClientDaoSupport
/*     */   implements ManageSetDAO
/*     */ {
/*     */   private RoleDAO roleDAO;
/*     */   private UserDAO userDAO;
/*     */   private BusinessTargetDAO businessTargetDAO;
/*     */ 
/*     */   public RoleDAO getRoleDAO()
/*     */   {
/*  31 */     return this.roleDAO;
/*     */   }
/*     */ 
/*     */   public void setRoleDAO(RoleDAO roleDAO) {
/*  35 */     this.roleDAO = roleDAO;
/*     */   }
/*     */ 
/*     */   public UserDAO getUserDAO() {
/*  39 */     return this.userDAO;
/*     */   }
/*     */ 
/*     */   public void setUserDAO(UserDAO userDAO) {
/*  43 */     this.userDAO = userDAO;
/*     */   }
/*     */ 
/*     */   public BusinessTargetDAO getBusinessTargetDAO() {
/*  47 */     return this.businessTargetDAO;
/*     */   }
/*     */ 
/*     */   public void setBusinessTargetDAO(BusinessTargetDAO businessTargetDAO) {
/*  51 */     this.businessTargetDAO = businessTargetDAO;
/*     */   }
/*     */ 
/*     */   public List getActivityManageSets() {
/*  55 */     return getSqlMapClientTemplate().queryForList("getActivityManageSets");
/*     */   }
/*     */ 
/*     */   public List getManageSetByType(String type) {
/*  59 */     return getSqlMapClientTemplate().queryForList("getManageSetByType", type);
/*     */   }
/*     */ 
/*     */   public ManageSet getManageSetByTypeStatus(ManageSet manageSet) {
/*  63 */     return (ManageSet)getSqlMapClientTemplate().queryForObject("getManageSetByTypeStatus", manageSet);
/*     */   }
/*     */ 
/*     */   public ManageSet getManageSetByCode(String code) {
/*  67 */     if (StringUtils.isEmpty(code)) return null;
/*  68 */     return (ManageSet)getSqlMapClientTemplate().queryForObject("getManageSetByCode", code);
/*     */   }
/*     */ 
/*     */   public List getManageSetObjectByManageSetId(Integer manageSetId) {
/*  72 */     return getSqlMapClientTemplate().queryForList("getManageSetObjectByManageSetId", manageSetId);
/*     */   }
/*     */ 
/*     */   public Integer getSalePersonCustomerLimit(Integer salePersonId) {
/*  76 */     if (salePersonId == null) return null;
/*  77 */     Integer value = new Integer(0);
/*  78 */     List list = new ArrayList();
/*  79 */     list = getManageSetByType("12");
/*  80 */     if (list != null) {
/*  81 */       for (int i = 0; i < list.size(); i++) {
/*  82 */         ManageSet manageSet = new ManageSet();
/*  83 */         manageSet = (ManageSet)list.get(i);
/*  84 */         if (("isUnify".equals(manageSet.getCode())) && ("1".equals(manageSet.getStatus()))) {
/*  85 */           if (!StringUtils.isEmpty(manageSet.getMValue()))
/*  86 */             value = Integer.valueOf(Integer.parseInt(manageSet.getMValue()));
/*     */         }
/*  88 */         else if (("isTarget".equals(manageSet.getCode())) && ("1".equals(manageSet.getStatus()))) {
/*  89 */           BigDecimal currentSalePersonTarget = new BigDecimal(0);
/*  90 */           currentSalePersonTarget = this.businessTargetDAO.getYearTargetBySalePersonId(salePersonId);
/*  91 */           System.out.println(currentSalePersonTarget);
/*  92 */           if ((currentSalePersonTarget != null) && (currentSalePersonTarget.compareTo(new BigDecimal(0)) > 0)) {
/*  93 */             double tValue = 0.0D;
/*  94 */             if (!StringUtils.isEmpty(manageSet.getMValue())) {
/*  95 */               tValue = Double.parseDouble(manageSet.getMValue());
/*  96 */               value = Integer.valueOf(Integer.parseInt(currentSalePersonTarget.multiply(BigDecimal.valueOf(tValue))
/*  97 */                 .divide(new BigDecimal(100), 0, 4).toString()));
/*     */             }
/*     */           }
/*     */         }
/* 101 */         else if (("isRole".equals(manageSet.getCode())) && ("1".equals(manageSet.getStatus()))) {
/* 102 */           Role role = new Role();
/* 103 */           Users user = new Users();
/* 104 */           user = this.userDAO.getUser(salePersonId);
/* 105 */           if (user != null) {
/* 106 */             role = this.roleDAO.getRole(user.getRoleId());
/* 107 */             if ((role != null) && (role.getMaxLimitNum() != null)) {
/* 108 */               value = role.getMaxLimitNum();
/*     */             }
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 114 */     return value;
/*     */   }
/*     */ 
/*     */   public List getRepeatSets() {
/* 118 */     List manageSetObjects = new ArrayList();
/*     */ 
/* 120 */     ManageSet mSet = new ManageSet();
/* 121 */     ManageSet manageSet = new ManageSet();
/* 122 */     manageSet.setMType("5");
/* 123 */     mSet = getManageSetByTypeStatus(manageSet);
/* 124 */     if (mSet != null) {
/* 125 */       manageSetObjects = getManageSetObjectByManageSetId(mSet.getId());
/*     */     }
/*     */ 
/* 128 */     return manageSetObjects;
/*     */   }
/*     */ 
/*     */   public BigDecimal getAvgSingle() {
/* 132 */     BigDecimal avgSingle = new BigDecimal(0);
/* 133 */     List list = new ArrayList();
/* 134 */     list = getManageSetByType("4");
/* 135 */     if ((list == null) || (list.size() <= 0)) return avgSingle;
/* 136 */     ManageSet manageSet = new ManageSet();
/* 137 */     manageSet = (ManageSet)list.get(0);
/* 138 */     avgSingle = new BigDecimal(manageSet.getMValue());
/* 139 */     return avgSingle;
/*     */   }
/*     */ 
/*     */   public int isUseCommons() {
/* 143 */     int result = 0;
/* 144 */     ManageSet manageSet = new ManageSet();
/* 145 */     manageSet.setMType("31");
/* 146 */     List list = new ArrayList();
/* 147 */     list = getManageSetByType("31");
/* 148 */     if ((list != null) && (list.size() > 0)) {
/* 149 */       manageSet = (ManageSet)list.get(0);
/* 150 */       if (manageSet != null) {
/* 151 */         result = Integer.parseInt(manageSet.getStatus());
/*     */       }
/*     */     }
/* 154 */     return result;
/*     */   }
/*     */ 
/*     */   public List isRepeatSet()
/*     */   {
/* 163 */     List manageSetObjects = new ArrayList();
/*     */ 
/* 165 */     ManageSet mSet = new ManageSet();
/* 166 */     ManageSet manageSet = new ManageSet();
/* 167 */     manageSet.setMType("5");
/* 168 */     mSet = getManageSetByTypeStatus(manageSet);
/* 169 */     if ((mSet != null) && ("0".equals(mSet.getStatus()))) {
/* 170 */       manageSetObjects = getManageSetObjectByManageSetId(mSet.getId());
/*     */     }
/*     */ 
/* 173 */     return manageSetObjects;
/*     */   }
/*     */ 
/*     */   public boolean isStartWarning() {
/* 177 */     ManageSet manageSet = new ManageSet();
/* 178 */     manageSet = getManageSetByCode("isStartWarning");
/* 179 */     if (manageSet == null) return false;
/* 180 */     if (StringUtils.isEmpty(manageSet.getStatus())) return false;
/* 181 */     return "1".equals(manageSet.getStatus());
/*     */   }
/*     */ 
/*     */   public boolean isWarningWay(String code)
/*     */   {
/* 186 */     if (StringUtils.isEmpty(code)) return false;
/* 187 */     ManageSet manageSet = new ManageSet();
/* 188 */     manageSet = getManageSetByCode(code);
/* 189 */     if (manageSet == null) return false;
/* 190 */     if (StringUtils.isEmpty(manageSet.getStatus())) return false;
/* 191 */     return "1".equals(manageSet.getStatus());
/*     */   }
/*     */ 
/*     */   public boolean isExpUser(Integer userId)
/*     */   {
/* 196 */     if (userId == null) return false;
/*     */ 
/* 198 */     ManageSet manageSet = new ManageSet();
/* 199 */     manageSet = getManageSetByCode("isExpUser");
/* 200 */     if (manageSet == null) return false;
/* 201 */     if ((StringUtils.isEmpty(manageSet.getStatus())) || (!"1".equals(manageSet.getStatus()))) return false;
/* 202 */     if (StringUtils.isEmpty(manageSet.getMValue())) return false;
/* 203 */     String strUserIds = manageSet.getMValue();
/* 204 */     String[] userIds = strUserIds.split(",");
/* 205 */     if ((userIds == null) || (userIds.length <= 0)) return false;
/* 206 */     for (int i = 0; i < userIds.length; i++) {
/* 207 */       if (userId.compareTo(Integer.valueOf(Integer.parseInt(userIds[i]))) == 0) {
/* 208 */         return true;
/*     */       }
/*     */     }
/* 211 */     return false;
/*     */   }
/*     */ 
/*     */   public boolean insertManageSetObject(ManageSetObject manageSetObject) {
/* 215 */     Integer result = (Integer)getSqlMapClientTemplate().insert("insertManageSetObject", manageSetObject);
/* 216 */     return true;
/*     */   }
/*     */ 
/*     */   public boolean updateManageSetByCode(ManageSet manageSet) {
/* 220 */     Integer result = Integer.valueOf(getSqlMapClientTemplate().update("updateManageSetByCode", manageSet));
/* 221 */     return result != null;
/*     */   }
/*     */ 
/*     */   public boolean updateManageSetByType(ManageSet manageSet)
/*     */   {
/* 226 */     Integer result = Integer.valueOf(getSqlMapClientTemplate().update("updateManageSetByType", manageSet));
/* 227 */     return result != null;
/*     */   }
/*     */ 
/*     */   public boolean deleteManageSetObject(Integer manageSetId)
/*     */   {
/* 232 */     Integer result = Integer.valueOf(getSqlMapClientTemplate().delete("deleteManageSetObject", manageSetId));
/* 233 */     return result != null;
/*     */   }
/*     */ 
/*     */   public boolean deleteManageSetObjectByType(String manageSetType)
/*     */   {
/* 238 */     Integer result = Integer.valueOf(getSqlMapClientTemplate().delete("deleteManageSetObjectByType", manageSetType));
/* 239 */     return result != null;
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.dao.impl.ManageSetDAOImpl
 * JD-Core Version:    0.6.0
 */